from Tkinter import *
from client import *
from tkSimpleDialog import *

class ClassesFrame(Frame):
    """
    Represents the frame that provides a user interface to access a project's CRCs information.
    """
    
    def __init__(self, parentControl, project, serverProxy):
        Frame.__init__(self, parentControl)
        self.parentControl = parentControl
        self.project = project
        self.serverProxy = serverProxy
        
        self.classes = serverProxy.getProjectClasses(project.id)
        
        label = Label(parentControl, text="Classes:")
        label.grid()

        self.classesListbox = Listbox(parentControl)
        self.classesListbox.grid(row=1)
        for crc in self.classes:
            self.classesListbox.insert(END, crc.name)
        
        button = Button(parentControl, text="Nouvelle classe", command=self.createClass)
        button.grid(row=2)
        
        self.crcFrame = Frame(parentControl)
        self.crcFrame.grid(column=0, rowspan=3)
        
    def createClass(self):
        pass
        
if __name__ == "__main__":
    root = Tk()
    client = ServerProxy()
    project = client.createProject("Foo", "Bar", "Frob")
    client.createClass(project.id, "Foo")
    client.createClass(project.id, "Bar")
    frame = ClassesFrame(root, project, client)
    root.mainloop()